<?php
    $lastChapter = $novel->chapter[0]['chapter'];
?>
<div class="chapter-navi visible-xs" class="row">
    <span class="menu-button" id="tblcontents"><i class="fa fa-bars"></i></span>
</div>

<div class="col-md-12 col-sm-12 col-lg-10 ctnWpr">
    <div class="alert alert-info">	
        <div class="row baseInfo">
            <?php if($novel->cover != '') { ?>
            <div class="chapter-image col-md-3 col-sm-3 col-lg-3 hidden-xs">
                <img class="img-rounded" style="max-width: 100%" src="<?php echo STATIC_URL . $novel->cover ?>"/>
            </div><!--chapter-image-->
            <?php } ?>
            <div class="chapter-info col-xs-12 col-md-9 col-sm-9 col-lg-9">
                <h2 class="novelTitle"><?= $novel->name; ?></h2>
                <div class="row">
                    <div class="col-md-2 col-sm-3 col-xs-5 col-lg-2"><strong>Tên khác:</strong></div>
                    <div class="col-md-10 col-sm-9 col-xs-7 col-lg-10"><p><?= $novel->name; ?></p></div>
                </div>
                <div class="row">
                    <div class="col-md-2 col-sm-3 col-xs-5 col-lg-2"><strong>Tác giả:</strong></div>
                    <div class="col-md-10 col-sm-9 col-xs-7 col-lg-10"><p><?= $novel->author; ?></p></div>
                </div>
                <div class="row">
                    <div class="col-md-2 col-sm-3 col-xs-5 col-lg-2"><strong>Thể loại:</strong></div>
                    <div class="col-md-10 col-sm-9 col-xs-7 col-lg-10">
                        <p>
                            <?php $i = 0;
                                foreach($novel->cats as $c) {
                                    echo '<a href="/the-loai/' . $c->slug . '">' . $c->name . '</a>';
                                    if(++$i != count($novel->cats))
                                        echo ', ';
                                }
                            ?>
                        </p>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-2 col-sm-3 col-xs-5 col-lg-2"><strong>Mới nhất:</strong></div>
                    <div class="col-md-10 col-sm-9 col-xs-7 col-lg-10">
                        <p style="line-height: 25px;">
                            <a href="/truyen/<?=$novel->slug?>/chuong/<?= $lastChapter?>">
                                Chương <?= $lastChapter ?>
                            </a>
                        </p>
                    </div>
                </div>
            </div><!--chapter-info--> 
        </div>
        <div class="row">
            <div class="col-md-12">
                <strong>Tóm tắt:</strong>
                <p style="line-height: 25px;"><?= $novel->description; ?></p>
            </div>
        </div>
    </div>
    <br/><br/>
    <?php if (count($novel->chapter) > 0): ?>
        <table class="table table-hover"> 
            <thead>
                <tr>
                    <th style="width: 100px;">Chương</th>
                    <th></th>
                    <th class="hidden-xs">Ngày update</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($novel->chapter as $chapter): ?>
                    <tr>
                        <td>
                            <a href="<?= base_url() ?>truyen/<?= $novel->slug ?>/chuong/<?= $chapter['chapter'] ?>">
                                Chương <?= $chapter['chapter'] ?>
                            </a>
                        </td>
                        <td>
                            <a href="<?= base_url() ?>truyen/<?= $novel->slug ?>/chuong/<?= $chapter['chapter'] ?>">
                                <?= $chapter['title'] ?>
                            </a>    
                        </td>
                        <td class="hidden-xs"><?= date('d/m/Y', $chapter['update']) ?></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    <?php endif; ?>
</div>